package Month11.Day8;

import java.util.*;

public class MapTest {
    public static void main(String[] args) {
        Map<String ,String> pet = new HashMap();
        pet.put("dog", "狗");
        pet.put("cat", "猫");
        Iterator iterator = pet.keySet().iterator();
        while (iterator.hasNext()) {
            Object key = iterator.next();
            System.out.println(key + "=" + pet.get(key));
        }
        Scanner in = new Scanner(System.in);
        System.out.println("请输入key");
        String key1 = in.next();
        if (pet.containsKey(key1)) {
            System.out.println(pet.get(key1));
        } else {
            System.out.println("输入错误，请重新输入！");

        }
        System.out.println("请输入value");
        String value = in.next();

        for (Map.Entry<String, String> m : pet.entrySet()) {
            if (m.getValue().equals(value)) {

                System.out.println(m.getKey());
            }


        }


    }
}


